package com.hexiang.rocketmq.producer.controller;

import javax.annotation.Resource;

import com.hexiang.rocketmq.producer.config.KafkaProducerConstant;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("kafka")
public class KafkaController {

    @Resource
    private KafkaTemplate<String, String> kafkaTemplate;

    @RequestMapping("send/{msg}")
    public String send(@PathVariable String msg) {
        kafkaTemplate.send(KafkaProducerConstant.KAFKA_TOPIC_ITOPENER_DEMO, msg);
        return "ok";
    }
}
